package com.bwf.lock;

import java.util.concurrent.locks.LockSupport;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/20 14:52
 * @Copyright 博为峰
 */
public class LockSupportDemo {
    public static void main(String[] args) throws InterruptedException {
        final Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + ",张三");
                LockSupport.park();//阻塞
                System.out.println(Thread.currentThread().getName() + ",李四");
            }
        });
        thread.start();
        Thread.sleep(1000);
        System.out.println(Thread.currentThread().getName() + ",王五");
        LockSupport.unpark(thread);//唤醒
    }
}
